/**
 * 
 */

$(document).ready(function() {
	
	var id = $("#userId").val();
	var sex = $("#sex option:selected").val();
/*时*/
	var state = $("#state option:selected").val();
	//搜索查询
	$("#search").click(function(){
		var id = $("#userId").val();
		var sex = $("#sex option:selected").val();
		var state = $("#state option:selected").val();
		var pageSize = $('#pageSize').val();
		window.location.href="initUser?id="+id+"&sex="+sex+"&state="+state +"&pageSize="+pageSize+"&currentPage=0";
		//window.location.href="initMyOrder?id="+id+"&startDate="+startDate+"&endDate="+endDate+"&state="+state;
	})
	
	//点击下一页
	$("#nextPage").click(function(){ 
		var pageSize = $('#pageSize').val();
		var currentPage = $('#currentPage').html();
		var totalPage = $('#totalPage').html();
		if(currentPage == totalPage){
			return ;
		}
		window.location.href="initUser?id="+id+"&sex="+sex+"&state="+state +"&pageSize="+pageSize+"&currentPage="+currentPage;
    });  
	//点击上一页
	$("#parentPage").click(function(){ 
		var pageSize = $('#pageSize').val();
		var currentPage = $('#currentPage').html();
		if(currentPage == 1){
			return ;
		}
		window.location.href="initUser?id="+id+"&sex="+sex+"&state="+state +"&pageSize="+pageSize+"&currentPage="+(currentPage-2);

    }); 
	//点击首页
	$("#firstPage").click(function(){ 
		var pageSize = $('#pageSize').val();
		window.location.href="initUser?id="+id+"&sex="+sex+"&state="+state +"&pageSize="+pageSize+"&currentPage=0";

    }); 
	
	//点击尾页
	$("#lastPage").click(function(){ 
		var pageSize = $('#pageSize').val();
		var totalPage = $('#totalPage').html();
		window.location.href="initUser?id="+id+"&sex="+sex+"&state="+state +"&pageSize="+pageSize+"&currentPage="+(totalPage-1);
    }); 
	
	//页面大小
	$("#pageSize").change(function(){ 
		var pageSize = $('#pageSize').val();
		window.location.href="initUser?id="+id+"&sex="+sex+"&state="+state +"&pageSize="+pageSize+"&currentPage=0";
	});
	
	//跳转
	$("#selectPage").change(function(){ 
		var pageSize = $('#pageSize').val();
		var jumpPage = $("#selectPage option:selected").val();
		window.location.href="initUser?id="+id+"&sex="+sex+"&state="+state +"&pageSize="+pageSize+"&currentPage="+(jumpPage-1);
	});
	
	//状态处理
	$("body").on("click",".dongj",function(){
		var uid = $(this).parent().parent().find(".uid").html();
		var s_this = $(this);
		$.get(
			"user/editState",
			{"id":uid,"state":1},
			function(){
				var ssss = s_this.parent().parent().find(".show").html();
				s_this.parent().parent().find(".show").html("冻结");
				s_this.val("0");
				s_this.html("解冻");
				s_this.attr("class","jdong");
			}
		)
	});
	$("body").on("click",".jdong",function(){
		var uid = $(this).parent().parent().find(".uid").html();
		var s_this = $(this);
		$.get(
			"user/editState",
			{"id":uid,"state":0},
			function(){
				s_this.parent().parent().find(".show").html("正常");
				s_this.val("1");
				s_this.html("冻结");
				s_this.attr("class","dongj");
			}
		)
	})
	
})